﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Web.Configuration;


namespace DAL
{
    public class SQLConnection
    {
        public static SqlConnection Conn;
        string str = WebConfigurationManager.ConnectionStrings["strcon"].ToString();
        public SQLConnection()
        { 
             if (Conn == null)
                {
                    Conn=new SqlConnection(str);
                }   
             
        }

        public static SqlConnection Opencon()
        {
            if (Conn.State==ConnectionState.Closed)
                {
                    Conn.Open();
                    return Conn;
                }
            return Conn;
        }

        public static void Closecon()
        {
            if(Conn.State==ConnectionState.Open)
            {
                Conn.Close();
                Conn.Dispose();
                Conn = null;
            }
        }


    }
}
